package com.devilvan.betrice.aiqicha.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devilvan.betrice.aiqicha.dto.AiqichaHeaderDto;
import com.devilvan.betrice.aiqicha.po.AiqichaHeaderPo;
import com.devilvan.betrice.aiqicha.service.AiqichaHeaderService;
import com.devilvan.betrice.aiqicha.mapper.AiqichaHeaderMapper;
import com.devilvan.betrice.aiqicha.repository.AiqichaHeaderRepository;
import com.devilvan.betrice.util.UCopy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author Evad.Wu
* @Description 爱企查-基本信息 业务逻辑类
* @date 2022-09-24
*/
@Service
public class AiqichaHeaderServiceImpl extends ServiceImpl<AiqichaHeaderMapper, AiqichaHeaderPo> implements AiqichaHeaderService {
    @Resource(name = "aiqichaHeaderRepository")
    private AiqichaHeaderRepository aiqichaHeaderRepository;

    @Override
    public AiqichaHeaderPo saveUpdate(AiqichaHeaderDto aiqichaHeaderDto) {
        AiqichaHeaderPo aiqichaHeaderPo = new AiqichaHeaderPo();
        UCopy.fullCopy(aiqichaHeaderDto, aiqichaHeaderPo);
        return aiqichaHeaderRepository.saveAndFlush(aiqichaHeaderPo);
    }

    @Override
    public List<AiqichaHeaderPo> saveUpdateBatch(List<AiqichaHeaderDto> list) {
        List<AiqichaHeaderPo> aiqichaHeaderPoList = UCopy.fullCopyCollections(list, AiqichaHeaderPo.class);
        return aiqichaHeaderRepository.saveAllAndFlush(aiqichaHeaderPoList);
    }
}
